package com.lzq.leetcode.lanqiao;

import java.util.Map;
import java.util.Scanner;
public class s505 {


    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[][] tri = new int[N][];
        int[][] dp = new int[N][];

        for (int i=1; i<=N; i++) {
            tri[i-1] = new int[i];
            dp[i-1] = new int[i];
            for (int j=0; j<i; j++) {
                tri[i-1][j] = scan.nextInt();
            }
        }

        scan.close();

        dp[0][0] = tri[0][0];
        for (int i=1; i<N; i++) {
            for (int j=0; j<i; j++) {
                if (j == 0) dp[i][j] = dp[i-1][j] + tri[i][j];
                else if (j == i) dp[i][j] = dp[i-1][j-1] + tri[i][j];
                else dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-1]) + tri[i][j];
            }
        }

        // 找到满足题意的
        int max = N % 2 == 0 ? Math.max(dp[N-1][N/2], dp[N-1][N/2-1]) : dp[N-1][N/2];


        System.out.println(max);
        //在此输入您的代码...
    }

}
